--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_toramuru_shou = General:new(extension, "hy_toramuru_shou", "ten_k", 4, 4, General.Female)
    local stateliness_of_hijiri = fk.CreateSkill {
        name = "stateliness_of_hijiri",
    }
    stateliness_of_hijiri:addEffect("active", {
        card_num = 2,
        card_filter = function(self, player, to_select, selected)
            return #selected < 2 and table.contains(player:getCardIds("he"), to_select) and not player:prohibitDiscard(to_select)
        end,
        target_filter = Util.FalseFunc,
        can_use = function(self, player)
            return player:hasSkill(self)
        end,
        prompt = function(self, selected_cards, selected_targets)
            return "stateliness_of_hijiri_prompt"
        end,
        on_use = function(self, room, cardUseEvent)
            local player = cardUseEvent.from
            room:throwCard(cardUseEvent.cards, stateliness_of_hijiri.name, player, player)
            room:addPlayerMark(player, "@stateliness_of_hijiri-turn", 1)
        end,
    })
    stateliness_of_hijiri:addEffect("targetmod", {
        bypass_distances = function(self, player, skill, card, to)
            if player:hasSkill(self) and player:getMark("@stateliness_of_hijiri-turn") > 0 and card and (card.trueName == "slash" or card:isCommonTrick()) then
                return true
            end
        end,
        bypass_times = function(self, player, skill, scope, card, to)
            if player:hasSkill(self) and player:getMark("@stateliness_of_hijiri-turn") > 0 and card and (card.trueName == "slash" or card:isCommonTrick()) then
                return true
            end
        end
    })
    stateliness_of_hijiri:addEffect(fk.CardUsing, {
        can_trigger = function(self, event, target, player, data)
            if not player:hasSkill(self) then
                return false
            end
            return player:getMark("@stateliness_of_hijiri-turn") > 0 and (data.card.trueName == "slash" or data.card:isCommonTrick())
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            event:setCostData(self, HY.AskForAddTarget(player, player:getMark("@stateliness_of_hijiri-turn"), true, false,
                "stateliness_of_hijiri_prompt_target:::" .. data.card:toLogString() .. ":" .. tostring(player:getMark("@stateliness_of_hijiri-turn")), stateliness_of_hijiri.name, data))
            room:setPlayerMark(player, "@stateliness_of_hijiri-turn", 0)
            return #event:getCostData(self) > 0
        end,
        on_use = function(self, event, target, player, data)
            HY.ChangeTarget(data, event:getCostData(self))
        end
    })
    stateliness_of_hijiri:addEffect(fk.AfterCardsMove, {
        can_trigger = function(self, event, target, player, data)
            if not player:hasSkill(self) then
                return false
            end
            local cards = {}
            for _, move in ipairs(data) do
                if move.from and move.from == player then
                    for _, info in ipairs(move.moveInfo) do
                        if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
                            local card = Fk:getCardById(info.cardId)
                            cards[card.color] = (cards[card.color] or 0) + 1
                        end
                    end
                end
            end
            return table.any(cards, function(value)
                return value >= 2
            end)
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            return room:askToSkillInvoke(player, {
                skill_name = stateliness_of_hijiri.name,
                prompt = "stateliness_of_hijiri_prompt_draw"
            })
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:drawCards(player, 1, stateliness_of_hijiri.name)
        end
    })
    local preach_justice = fk.CreateSkill {
        name = "preach_justice",
    }
    preach_justice:addEffect(fk.EventPhaseStart, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self) and target == player and target.phase == Player.Finish and #player:getCardIds("h") == 0
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local cards = {}
            for _, name in ipairs(Fk:getAllCardNames("t")) do
                local card = Fk:cloneCard(name)
                if card.multiple_targets and not table.contains(player:getTableMark("@$preach_justice"), card.name) and table.any(room.players, function(to)
                        return player:canUseTo(card, to) or false
                    end) then
                    table.insertIfNeed(cards, card.name)
                end
            end
            if #cards > 0 then
                table.insertIfNeed(cards, "Cancel")
                event:setCostData(self, room:askToChoice(player, {
                    choices = cards,
                    skill_name = preach_justice.name,
                    prompt = "preach_justice_prompt"
                }))
                return event:getCostData(self) ~= "Cancel"
            end
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local marks = player:getTableMark("@$preach_justice")
            table.insertIfNeed(marks, event:getCostData(self))
            room:setPlayerMark(player, "@$preach_justice", marks)
            room:drawCards(player, 2, preach_justice.name)
            room:askToUseVirtualCard(player, {
                name = event:getCostData(self),
                skill_name = preach_justice.name,
                cancelable = false,
            })
        end
    })
    extension:loadSkillSkels { stateliness_of_hijiri, preach_justice }
    hy_toramuru_shou:addSkill("stateliness_of_hijiri")
    hy_toramuru_shou:addSkill("preach_justice")
    Fk:loadTranslationTable {
        ["hy_toramuru_shou"] = "寅丸星",
        ["#hy_toramuru_shou"] = "肃面金虎",
        ["designer:hy_toramuru_shou"] = "黑曜人形",
        ["illustrator:hy_toramuru_shou"] = ".SIN",
        ["cv:hy_toramuru_shou"] = "",

        ["stateliness_of_hijiri"] = "圣威",
        [":stateliness_of_hijiri"] = "出牌阶段，你可以弃置两张牌并令你本回合使用的下一张【杀】或普通锦囊牌无距离次数限制且可以增加或减少一个目标。在你失去牌后，若其中有至少两张牌颜色相同，你可以摸一张牌。",
        ["@stateliness_of_hijiri-turn"] = "圣威",
        ["stateliness_of_hijiri_prompt"] = "圣威：你可以弃置两张牌",
        ["stateliness_of_hijiri_prompt_target"] = "圣威：你可以为%arg增减共计%arg2个目标",
        ["stateliness_of_hijiri_prompt_draw"] = "圣威：你可以摸一张牌",

        ["preach_justice"] = "宣义",
        [":preach_justice"] = "结束阶段，若你没有手牌，你可以摸两张牌并视为使用一张多目标锦囊牌（每牌名限一次）。",
        ["@$preach_justice"] = "宣义",
        ["preach_justice_prompt"] = "宣义：你可以摸两张牌并视为使用一张多目标锦囊牌",
    }
end
